﻿Imports System.Windows.Forms

Public Class dlgSettings

    Public result As String
    Public isLocal As Boolean

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        If Not IO.File.Exists(txtZunePath.Text + "\Zune.exe") Then
            MsgBox("Please select a valid path to your Zune Software", MsgBoxStyle.Critical, "Settings error")
            Exit Sub
        End If

        MsgBox("Some changes will only take effect after you restart the application!", MsgBoxStyle.Exclamation, "Changed settings")

        ZuneHelpers.RelocateZuneDLLs()

        My.Settings.Save()
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub OnClose(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If Not IO.File.Exists(txtZunePath.Text + "\Zune.exe") Then
            MsgBox("Please select a valid path to your Zune Software", MsgBoxStyle.Critical, "Settings error")
            e.Cancel = True
        End If
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        My.Settings.Reload()
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub btnBrowseSoftwareDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowseSoftwareDir.Click
        If FolderBrowser.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtZunePath.Text = FolderBrowser.SelectedPath
        End If
    End Sub
End Class
